﻿<Window x:Class="TemplatingSample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <Style TargetType="{x:Type Button}" x:Key="buttonStyle">
            <Setter Property="FocusVisualStyle">
                <Setter.Value>
                    <Style>
                        <Setter Property="Control.Template">
                            <Setter.Value>
                                <ControlTemplate>
                                    <Rectangle Margin="2"
                                             SnapsToDevicePixels="True" 
                                             Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" 
                                             StrokeThickness="1" 
                                             StrokeDashArray="1 2"/>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </Setter.Value>
            </Setter>
            <Setter Property="Background" Value="#FFDDDDDD"/>
            <Setter Property="BorderBrush" Value="#FF707070"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Padding" Value="1"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Ellipse x:Name="border" 
                                     Stroke="{TemplateBinding BorderBrush}"
                                     StrokeThickness="{TemplateBinding BorderThickness}"
                                     Fill="{TemplateBinding Background}" 
                                     SnapsToDevicePixels="True"/>
                            <Border>
                                <ContentPresenter x:Name="contentPresenter" 
                                                  ContentTemplate="{TemplateBinding ContentTemplate}"
                                                  Content="{TemplateBinding Content}"
                                                  ContentStringFormat="{TemplateBinding ContentStringFormat}" 
                                                  Focusable="False"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  Margin="{TemplateBinding Padding}"
                                                  RecognizesAccessKey="True"
                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsDefaulted" Value="True">
                                <Setter Property="Stroke" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Fill" TargetName="border" Value="#FFBEE6FD"/>
                                <Setter Property="Stroke" TargetName="border" Value="#FF3C7FB1"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="Fill" TargetName="border" Value="#FFC4E5F6"/>
                                <Setter Property="Stroke" TargetName="border" Value="#FF2C628B"/>
                            </Trigger>
                            <Trigger Property="ToggleButton.IsChecked" Value="True">
                                <Setter Property="Fill" TargetName="border" Value="#FFBCDDEE"/>
                                <Setter Property="Stroke" TargetName="border" Value="#FF245A83"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Fill" TargetName="border" Value="#FFF4F4F4"/>
                                <Setter Property="Stroke" TargetName="border" Value="#FFADB2B5"/>
                                <!--<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="#FF838383"/>-->
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <StackPanel>
        <Button Content="Hello world - How are you? - I`m good"
                HorizontalAlignment="Center" 
                VerticalAlignment="Center"
                Style="{StaticResource buttonStyle}"/>
        <Button Content="Hello world - How are you? - I`m good"
                HorizontalAlignment="Center" 
                VerticalAlignment="Center"/>
    </StackPanel>
</Window>
